package com.tianshuo.condition.config;

import com.tianshuo.condition.model.Cat;
import com.tianshuo.condition.model.Dog;
import com.tianshuo.condition.model.Person;
import com.tianshuo.condition.model.PersonCondition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@ComponentScan("com.tianshuo.condition")
@Configuration
public class ConditionalConfig {


    /**
     * 测试说明@Bean注解是按照配置的先后顺序来注册bd的,测试person还未被解析到bdm中.,所以不满足条件
     * cat不会被注册到bdm中
     *
     * @Conditional 注解的作用,满足PersonCondition.class类中要求才会触发cat的@Bean
     * @return
     */
    @Conditional(PersonCondition.class)
    @Bean
    public Cat cat() {
        return new Cat();
    }

    @Bean
    public Person person() {
        return new Person();
    }

    @Bean
    public Dog dog() {
        return new Dog();
    }



}
